package com.gf.exam.dao;

import java.util.Date;
import java.util.List;

import com.gf.base.type.ExamType;
import com.gf.base.type.PlayMode;
import com.gf.common.bean.Page;
import com.gf.exam.model.Cell;
import com.gf.exam.model.Exam;
import com.gf.exam.model.Timer;

public interface ExamDao {

	/**
	 * 得到最新一条的测试项目
	 * 
	 * @return
	 */
	public Exam queryLatestExam();

	/**
	 * 返回 >date 的
	 * 
	 * @param date
	 * @return
	 */
	public List<Exam> queryExamByUpdatetime(Date date);

	/**
	 * 更新索引
	 * 
	 * @param currentPage
	 * @return
	 */
	public List<Exam> queryAllExamForLucene(int currentPage);

	/**
	 * 得到测试用例总数
	 * 
	 * @return
	 */
	public int queryExamNumber();

	/**
	 * 插入
	 * 
	 * @param userId
	 * @param userName
	 * @param title
	 * @param introduction
	 * @param cellNo
	 * @param timer
	 * @param examType
	 * @return
	 */
	public long insert(long userId, String userName, String title,
			String introduction, int cellNo, boolean active, int repeatFrom,
			int repeatTo, PlayMode playMode, int repeatTime, Timer timer,
			ExamType examType);

	/**
	 * 更新项目
	 * 
	 * @param examId
	 * @param userName
	 * @param title
	 * @param introduction
	 * @param cellNo
	 * @param timer
	 * @param examType
	 * @return
	 */
	public void update(long examId, String title, String introduction,
			int cellNo, boolean active, int repeatFrom, int repeatTo,
			PlayMode playMode, int repeatTime, Timer timer, ExamType examType);

	/**
	 * 更新项目类型
	 * 
	 * @param examId
	 * @param examType
	 */
	public void update(long examId, ExamType examType);

	/**
	 * 通过ID查找
	 * 
	 * @param id
	 * @return
	 */
	public Exam queryById(long id);

	/**
	 * 通过用户ID
	 * @param id
	 * @param userId
	 * @return
	 */
	public Exam queryByIdAndUserId(long id,long userId);
	
	/**
	 * 批量查询
	 * 
	 * @param ids
	 * @return
	 */
	public List<Exam> queryBatchById(List<Long> ids);

	/**
	 * 
	 * @param userId
	 * @param page
	 * @return
	 */
	public List<Exam> queryByUserId(long userId, Page page,ExamType examType);

	public List<Exam> queryAll(Page page);

	public int queryTotalCount(long userId,ExamType examType);

	public boolean delete(long id);
	
	/**
	 * 项目提交+1
	 * @param examId
	 */
	public void updateSubmitNoByOne(long examId);
	
	
	/**
	 * 得到该PPT下的所有内容
	 * @param examId
	 * @return
	 */
	public List<Cell> queryAllCells(long examId);

}
